import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter); //将路由注入到vue的所有子组件中中
//1.定义组件
//2.定义路由  此处为定义路由 const routes=[]
//3.注册路由
//4.挖坑
const routes = [
  // { path: "/", component: () => import("../views/login/login.vue") },
  { path: "/login", component: () => import("../views/login/login.vue") },
  { path: "/duanxing", component: () => import("../views/login/duanxing.vue") },
  { path: "/lingpai", component: () => import("../views/login/lingpai.vue") },
  {
    path: "/",
    name: "adminindex",
    redirect: "/login",
    component: () => import("../views/admin.vue"),
    children: [
      //后台首页-欢迎页
      {
        path: "welcome",
        component: () => import("../views/users/huanyi.vue"),
        meta: { name1: "后台首页", name2: "欢迎页" }
      },

      //后台首页-访客记录
      {
        path: "history",
        component: () => import("../views/users/history.vue"),
        meta: { name1: "后台首页", name2: "访客记录" }
      },

      //商品分类-分类列表，分类创建
      {
        path: "goods/cate",
        component: () => import("../views/goods/fenlei/index.vue"),
        meta: { name1: "商品分类", name2: "分类列表" }
      },
      {
        path: "goods/cate/create",
        component: () => import("../views/goods/fenlei/create.vue"),
        meta: { name1: "商品分类", name2: "分类创建" }
      },

      //商品属性-商品类型、类型创建、商品属性、属性创建(4个路径)
      {
        path: "goods/type",
        component: () => import("../views/goods/type/index.vue"),
        meta: { name1: "商品属性", name2: "商品类型" }
      },
      {
        path: "goods/type/create",
        component: () => import("../views/goods/type/create.vue"),
        meta: { name1: "商品属性", name2: "类型创建" }
      },
      {
        path: "goods/attr",
        component: () => import("../views/goods/shuxing/index.vue"),
        meta: { name1: "商品属性", name2: "商品属性" }
      },
      {
        path: "goods/attr/create",
        component: () => import("../views/goods/shuxing/create.vue"),
        meta: { name1: "商品属性", name2: "属性创建" }
      },

      //商品管理-商品列表，商品创建，商品回收站
      {
        path: "goods",
        component: () => import("../views/goods/guan/index.vue"),
        meta: { name1: "商品管理", name2: "商品列表" }
      },
      {
        path: "goods/create",
        component: () => import("../views/goods/guan/create.vue"),
        meta: { name1: "商品管理", name2: "商品创建" }
      },
      {
        path: "goods/recycle",
        component: () => import("../views/goods/guan/laji.vue"),
        meta: { name1: "商品管理", name2: "商品回收站" }
      },

      //订单管理-订单管理，订单回收站，订单统计
      {
        path: "orders",
        component: () => import("../views/orders/order/guan.vue"),
        meta: { name1: "订单管理", name2: "订单管理" }
      },
      {
        path: "orders/recycle",
        component: () => import("../views/orders/order/laji.vue"),
        meta: { name1: "订单管理", name2: "订单回收站" }
      },
      {
        path: "orders/total",
        component: () => import("../views/orders/order/tongji.vue"),
        meta: { name1: "订单管理", name2: "订单统计" }
      },

      //用户管理-用户列表，用户创建
      {
        path: "users",
        component: () => import("../views/yonghumen/yonghu.vue"),
        meta: { name1: "用户管理", name2: "用户列表" }
      },
      {
        path: "users/create",
        component: () => import("../views/yonghumen/create.vue"),
        meta: { name1: "用户管理", name2: "用户创建" }
      },

      //角色列表-角色列表，角色创建
      {
        path: "roles",
        component: () => import("../views/jueses/juese.vue"),
        meta: { name1: "角色列表", name2: "角色列表" }
      },
      {
        path: "roles/create",
        component: () => import("../views/jueses/create.vue"),
        meta: { name1: "角色列表", name2: "角色创建" }
      },

      //权限管理-权限列表
      {
        path: "auths",
        component: () => import("../views/quanxian/quan/xian.vue"),
        meta: { name1: "权限管理", name2: "权限列表" }
      }
    ]
  },
  { path: "/404", component: () => import("../views/404") },
  { path: "*", redirect: "/404" }
];
const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
